#pragma once


// cs - client to server
// sc - server to client
enum MessageType
{
   FromClientToClients = 0,
   FromClientToAll, // the same as FromClientToClients but also includes server
   FromClientToServer,
   FromServerToClient,
   FromServerToClients,
   FromClientToClient,
   LocalMessage,
   countOfMessages
};

enum MessagesEnum
{
   ShipsLaunched,
   ShipsArrived,
   InitialMessage,
   PingMessage,
   LoseGameState,
   WinGameState,
   TooManyPlayers,
   ErrorMessage
};

class Message
{
public:

   enum {header_length = 4};

   enum {max_body_length = 10000};

   char* GetData();

   const char* GetData() const;
      
   size_t GetLength() const;
   
   void SetBodyLength(const size_t newSize);

   size_t GetBodyLength() const;

   char* GetBody();

   const char* GetBody() const;
   
   void SetBody(const char * body);

   void EncodeHeader();

   bool DecodeHeader();

   Message();

   Message(const Message& message);

   ~Message();

private:

   char m_data[header_length + max_body_length];

   size_t m_bodyLength;
};

//typedef boost::shared_ptr<Message> MessagePtr;